Okay...I'm Fed up... last $#!% straw!
# support
e
Is anyone hosting or is embedding a Vapi assistant within their website? I'm creating a page behind a paywall/private website where the users can click on a specific icon (or whatever) and have the agent start the conversation. Everything works fine with my Assistant Demo here on Vapi, now it's time to have people use it. The code that Vapi AI Support Chatbot gave me does not work and there hasn't been any resolution on this. I will be switching platforms asap if I can't resolve this here. I had to cancel my previous demo, because we could not get the thing to work! var vapiInstance = null; const assistant = "1234567890"; // Substitute with your assistant ID const apiKey = "0123456789"; // Substitute with your Public key from Vapi Dashboard const buttonConfig = {}; // Modify this as required (function (d, t) { var g = document.createElement(t), s = d.getElementsByTagName(t)[0]; g.src = "https://cdn.jsdelivr.net/gh/VapiAI/html-script-tag@latest/dist/assets/index.js"; g.defer = true; g.async = true; s.parentNode.insertBefore(g, s); g.onload = function () { console.log("I'm here") vapiInstance = window.vapiSDK.run({ apiKey: apiKey, // mandatory assistant: assistant, // mandatory config: buttonConfig, // optional }); console.log("Betula",vapiInstance); }; })(document, "script"); function startConversation() { // Function to start the conversation vapi.send({ type: "add-message", message: { role: "system", content: "The user has clicked to start a conversation", }, }); }
v
Hi there! I understand your frustration with trying to embed your Vapi assistant on your website. Let me help you resolve this issue! 🔍 Looking at your code, I've identified the problem. In your
startConversation()
function, you're using
vapi.send()
, but the variable
vapi
is never defined. Instead, you should be using
vapiInstance.send()
since that's the variable you've defined when initializing the SDK. Here's how to fix your code:
Copy code
javascript
function startConversation() {
  // Function to start the conversation
  vapiInstance.send({
    type: "add-message",
    message: {
      role: "system",
      content: "The user has clicked to start a conversation",
    },
  });
}
This is a common issue when embedding Vapi assistants. According to the [troubleshooting documentation](https://docs.vapi.ai/examples/voice-widget), the
vapiSDK.run
function returns a
vapiInstance
that should be used to send messages and listen to events. Also, make sure that: 1. You've replaced the placeholder values for
assistant
and
apiKey
with your actual Assistant ID and Public API key from the Vapi Dashboard 2. The script is properly loaded before you try to use the
vapiInstance
3. Your browser console doesn't show any other errors that might be preventing the assistant from working The rest of your code looks good! The structure with the
vapiSDK.run
function is correct, as it includes the mandatory
apiKey
and
assistant
parameters, as well as the optional
config
parameter. Is there anything else you'd like me to help you with regarding your Vapi assistant implementation? Sources: - [Troubleshooting common issues when embedding Vapi assistant on a website](https://docs.vapi.ai/examples/voice-widget) - [Explanation of vapiSDK.run function in Vapi](https://docs.vapi.ai/sdks) - [Explanation of vapi.send function in Vapi](https://docs.vapi.ai/sdk/web)
e
Well, that did'nt work either!
s
@Elastic Could you record a Loom video describing the error response you're getting and what help you require to get it resolved? The error description makes me understand that something you're trying out with the SMS script tag isn't working for you. For me to understand better, you need to put a Loom video showing what you're trying to do and the web browser logs as well.
p
Thank you for reaching out to us. We've received your message and will get back to you as soon as possible.
Hi, checking if this is resolved/solved for you?
e
No, not resolved.
Loom video is not going to help, its just the peice of code to have the UI show the Vapi call icon and have it work. The icon shows up, but clicking it does nothing! var vapiInstance = null; const assistant = "abc123ABC"; // Substitute with your assistant ID const apiKey = "abc123ABC"; // Substitute with your Public key from Vapi Dashboard. const buttonConfig = {}; // Modify this as required (function (d, t) { var g = document.createElement(t), s = d.getElementsByTagName(t)[0]; g.src = "https://cdn.jsdelivr.net/gh/VapiAI/html-script-tag@latest/dist/assets/index.js"; g.defer = true; g.async = true; s.parentNode.insertBefore(g, s); g.onload = function () { vapiInstance = window.vapiSDK.run({ apiKey: apiKey, // mandatory assistant: assistant, // mandatory config: buttonConfig, // optional }); }; })(document, "script"); function startConversation() { // Function to start the conversation vapiInstance.send({ type: "add-message", message: { role: "system", content: "The user has clicked to start a conversation", }, }); }
Not working for me at all for some reason.
p
Hey Elastic, I went through the code shared by you. It looks good to me. Could you share the console logs as well?
e
@Shubham Bajaj The most recent Call Log ID: 5c6f5cbd-ceb9-4240-a60a-ca1e4fb15c87
Note: Those are just the calls that were tested via the "Assistant Demo", the actual page embed is still not working.
p
Hey Elastic, I just tested now on your website, and the AI Assistant is working. What's happening is you haven't configured your "Try our AI Assistant" button to trigger the call using VAPI HTML script tag, and that's why the calls are not being triggered. You have to fix your JavaScript code to make it work. If you require further assistance, please let me know. https://cdn.discordapp.com/attachments/1358111519996510409/1359298906986643507/image.png?ex=67f6f941&is=67f5a7c1&hm=8ea049d934a9810480b2b30a526cae3a0692f369e2424938997bf09466dca428& https://cdn.discordapp.com/attachments/1358111519996510409/1359298907305414666/image.png?ex=67f6f942&is=67f5a7c2&hm=2c2b6e2ff3c810c42bfa435757230a80c5e69d9c65756ba96adb2d938e348f12&
s
Ignore the first image
e
The button I'm actually trying to click on is the one generated by Vapi. The "Try our AI Assistant" is not active by choice, that will link to another page that list other Assistants. But now that you mentioned it, I also want to know how to link my buttons. So, still not working on my browser or on any of my 2 macbook, or my iMac desktop computers
@User I have deleted everything, and only left those two buttons. Still not working. https://verbalist.xyz/
Check here, even on the desktop version. I know this has been open multiple times. I want to help. It's been open long. DM me, and we'll call to resolve it if it's still happening. https://cdn.discordapp.com/attachments/1358111519996510409/1360023330437988573/image.png?ex=67f99bed&is=67f84a6d&hm=5c42b6f7d741bef6e024a2fd260f0af4464cafae8c800102a4bc4d819412d19f&